package com.amaze.escape.generators;

import com.amaze.escape.Configuration;
import com.amaze.escape.util.FastRandom;
import com.amaze.escape.util.PerlinNoise;
import com.amaze.escape.world.Chunk;

import sun.reflect.generics.reflectiveObjects.NotImplementedException;

/**
 * Generators are used to generate the basic terrain, to generate caves
 * and to populate the surface.
 *
 * @author Amaze Team
 */
public abstract class ChunkGenerator {

    /**
     * First Perlin noise generator.
     */
    protected PerlinNoise _pGen1;
    /**
     * Second Perlin noise generator.
     */
    protected PerlinNoise _pGen2;
    /**
     * Third Perlin noise generator.
     */
    protected PerlinNoise _pGen3;
    /**
     * Fast random number generator.
     */
    protected final FastRandom _rand;

    /**
     * Init. the generator with a given seed value.
     * 
     * @param seed
     */
    public ChunkGenerator(String seed) {
        _rand = new FastRandom(seed.hashCode());
        _pGen1 = new PerlinNoise(seed.hashCode());
        _pGen2 = new PerlinNoise(seed.hashCode()+1);
        _pGen3 = new PerlinNoise(seed.hashCode()+2);
    }

    /**
     * Apply the generation process to the given chunk.
     * 
     * @param c
     */
    public void generate(Chunk c) {
        throw new NotImplementedException();
    }

    /**
     * 
     * @param c
     * @return
     */
    public int getOffsetX(Chunk c) {
        return (int) c.getPosition().x * (int) Configuration.CHUNK_DIMENSIONS.x;
    }

    /**
     * 
     * @param c
     * @return
     */
    public int getOffsetY(Chunk c) {
        return (int) c.getPosition().y * (int) Configuration.CHUNK_DIMENSIONS.y;
    }

    /**
     * 
     * @param c
     * @return
     */
    public int getOffsetZ(Chunk c) {
        return (int) c.getPosition().z * (int) Configuration.CHUNK_DIMENSIONS.z;
    }
}
